﻿using ElsProp.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace ElsProp
{
    /// <summary>
    /// zhuangBeiList.xaml 的交互逻辑
    /// </summary>
    public partial class zhuangBeiList : UserControl
    {

        public string guid { get; set; }

        public string name { get; set; }
        public bool mouseFlag { get; set; }

        public event Action<object> RightClick;
        public zhuangBeiList()
        {
            InitializeComponent();
            this.AllowDrop = true;
            this.MouseDown += Zhuangbeilan_MouseDown;
            this.MouseMove += Zhuangbeilan_MouseMove;
            this.MouseUp += Zhuangbeilan_MouseUp;
            this.MouseDown += ZhuangBeiList_MouseDown;
        }

        private void ZhuangBeiList_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Right && e.ButtonState == MouseButtonState.Pressed)
            {
                RightClick?.Invoke(this.DataContext);
            }
        }

        private void Zhuangbeilan_MouseUp(object sender, MouseButtonEventArgs e)
        {

            mouseFlag = false;
        }

        private void Zhuangbeilan_MouseMove(object sender, MouseEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
                if (mouseFlag)
                {
                    DragDrop.DoDragDrop(this,
                                 this.DataContext,
                                 DragDropEffects.Copy);
                }
        }

        private void Zhuangbeilan_MouseDown(object sender, MouseButtonEventArgs e)
        {
            if (e.ChangedButton == MouseButton.Left)
            {
                mouseFlag = true;
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var data = this.DataContext;
        }
    }
}
